package com.alei.redis.redisdemo.controller;

import com.alei.redis.redisdemo.bean.User;
import com.alei.redis.redisdemo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.web.bind.annotation.*;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;

/**
 * @author ShiLei
 * @version v1.0
 * @date 2020-06-16 18:35
 */
@RestController
@CrossOrigin
@Slf4j
public class UserController {


    @Resource
    private UserService userService;

    @RequestMapping("/getUserById/{id}")
    public User getUserById(@PathVariable("id") Integer id) {

        return userService.getUserById(id);
    }

    @RequestMapping("/jedisDemo")
    public String jedisDemo() {
        return userService.jedisDemo();
    }

    public static void main(String[] args) {
        Jedis jedis = new Jedis("47.95.223.193",6382);
        jedis.set("shilei","ayu");
        String shilei = jedis.get("shilei");
        System.out.println(shilei);

        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        JedisPool jedisPool = new JedisPool(config,"47.95.223.193",6382);

        //简单使用

    }
}
